/*
* name;
*/
class Tool{
    constructor(){

    }

    /**
     * 角度转弧度
     * @param angle 角度
     */
    public static A2R(angle:number):number 
    {
        let radian:number = angle * Math.PI/180;
        return radian;
    }

    /**
     * 弧度转角度
     * @param radian 弧度
     */
    public static R2A(radian:number):number
    {
        let angle:number = radian*180 / Math.PI;
        return angle;
    }

    /**
     * 世界坐标到目标对象局部坐标 
     * @param worldPos
     * @param target
     * @return 
     * 
     */		
    public static worldToLocal(worldPos:Vector3, target:Laya.Transform3D):Vector3
    {
        var localPos:Vector3 = new Vector3();
        var offset:number = 0;
        var matrixInvert:Laya.Matrix4x4 = new Laya.Matrix4x4();
        target.worldMatrix.invert(matrixInvert);
        Laya.Utils3D.transformVector3ArrayToVector3ArrayCoordinate(localPos.elements, 0, matrixInvert, worldPos.elements, offset);
        return localPos;
    }
    
    /**
     * 转换2D屏幕坐标系统到3D投影坐标系统（仅限于正交投影）
     * @param	source 源坐标。
     * @param	out 输出坐标。
     */
    public static screenCoordTo3DCoord(source:Vector3, out:Vector3):void
    {
        let se:Float32Array = source.elements;
        let oe:Float32Array = out.elements;
        oe[0] = ((-GameConfig.deviceW >> 1) + se[0]) * GameConfig.UnitPerPixel;
        oe[1] = ((GameConfig.deviceH >> 1) - se[1]) * GameConfig.UnitPerPixel;
        oe[2] = se[2];
    }
}